#include <stdio.h>
#include "ofc/DConfig.h"

int main(int argc, char *argv[])
{
#ifdef HAVE_DCONFIG
  DConfigWriter *wrtr = [DConfigWriter new];
  DText         *dest = [DText         new];

  if (![wrtr startConfig :dest])       // Use text string as destination
    printf("Error in startConfig.\n");

  if (![wrtr comment :"Example config file"]) // Write a comment
    printf("Error in comment.\n");

  if (![wrtr section :"Section1"])      // Write a section in the 'config file'
    printf("Error in section.\n");
  
  if (![wrtr option :"Section1" :"Option1" :"Value1"]) // Write an option in the 'file'
    printf("Error in option.\n");

  if (![wrtr option :"Section1" :"Option2" :"Value2"])
    printf("Error in option.\n");

  if (![wrtr option :"Section2" :"Option1" :"Value1"]) // Write an option in the next section
    printf("Error in option.\n");

  [wrtr endConfig];

  printf("Config file:\n%s", [dest cstring]);

  [dest free];                         // Cleanup
  [wrtr free];
#else
  printf("DConfig is not present in the library.\n");
#endif
  return 0;
}

